﻿
@page "/Wms/SaleOutWarehouseDetail/Create"
@using nERP.ViewModel.Wms.SaleOutWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
  <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit" >
    <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
      <BootstrapInput @bind-Value="@Model.Entity.Seq"/>
      <Select @bind-Value="@Model.Entity.SaleOutWarehouseId" Items="AllSaleOutWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g4708f4f20d4b4e6e88c0e3c9bfd679c5"/>
      <BootstrapInput @bind-Value="@Model.Entity.SaleOutWarehouseDetailCode"/>
      <Select @bind-Value="@Model.Entity.SaleId" Items="AllSales" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g2a300c4159fd4f5cb198fd0ef97a4adc"/>
      <Select @bind-Value="@Model.Entity.SaleDetailId" Items="AllSaleDetails" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g57fc2b59f60d45a6ab7eb9362423a7d5"/>
      <Select @bind-Value="@Model.Entity.GoodsId" Items="AllGoodss" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g419be642de6a42798125d5a93a7d7f6b"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsName"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsSpec"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsUnit"/>
      <Select @bind-Value="@Model.Entity.WarehouseId" Items="AllWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="gaa9e374c19d1473c87f5da0a06d031fd"/>
      <BootstrapInput @bind-Value="@Model.Entity.SaleOutNumber"/>
      <BootstrapInput @bind-Value="@Model.Entity.Remark"/>
    </Row>

    <div class="modal-footer table-modal-footer">
      <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
      <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
    </div>

  </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SaleOutWarehouseDetailVM Model = new SaleOutWarehouseDetailVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {
                        
        
        await PostsForm(vform, "/api/Wms/SaleOutWarehouseDetail/Create", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllSaleOutWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllSales = new List<SelectedItem>();
    private List<SelectedItem> AllSaleDetails = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllSaleOutWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetSaleOutWarehouses");
        AllSaleOutWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSales = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetSales");
        AllSales.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSaleDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetSaleDetails");
        AllSaleDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
